<?php

/**
 * Get about us and bussinesses page
 */
function get_latest_content_custom_page($type = '') {
  $output = '';
  if (!empty($type)) {
    $query = db_select('node', 'n');
    $query->leftJoin('field_data_field_page_type', 't', 't.entity_id = n.nid');
    $query->condition('t.field_page_type_value', $type);
    $query->condition('n.type', 'custom_page');
    $query->condition('n.status', 1);
    $query->orderBy('n.created', 'DESC');
    $query->fields('n', array('nid'));
    $query->range(0, 1);
    $result = $query->execute()->fetchCol();
    $output = theme('tpl_' . $type, array('result' => $result));
  }
  return $output;
}

/**
 * @see m_front_menu
 * @file node--custom-page.tpl.php
 * 
 * Implements of get content other of custom page
 * 
 * @param integer $nid
 * @param key string $field_type_page
 * 
 * @result string theme
 */
function get_custom_page_other($nid, $field_type_page) {
  $content = '';
  if (!empty($nid) && !empty($field_type_page)) {
    $result = get_content_by_other(array($nid), 'custom_page', $field_type_page);
    $content = theme('tpl_custom_page_other', array('result' => $result));
  }  
  print drupal_json_encode(array('custom_data' => $content));
  die;
}
